package com.example.hadoopdemo1.reduce;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author cxx
 * @create 2020-02-09 10:47
 **/
public class WordCountReduce extends Reducer<Text,LongWritable,Text,LongWritable> {

    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {

        int count = 0;
        for (LongWritable lw : values) {
            count++;
        }
        System.out.println (key+":"+count);
        context.write (key,new LongWritable (count));
    }
}
